class Solution(object):
    def minCost(self, costs):
        """
        :type costs: List[List[int]]
        :rtype: int
        """
        n = len(costs)
        DP0 = [costs[0][0], 0]
        DP1 = [costs[0][1], 0]
        DP2 = [costs[0][2], 0]
        for i in range(1, n):
            DP0[i % 2] = min(DP1[(i + 1) % 2] + costs[i][0], DP2[(i + 1) % 2] + costs[i][0])
            DP1[i % 2] = min(DP0[(i + 1) % 2] + costs[i][1], DP2[(i + 1) % 2] + costs[i][1])
            DP2[i % 2] = min(DP0[(i + 1) % 2] + costs[i][2], DP1[(i + 1) % 2] + costs[i][2])
        return min(DP0[(n + 1) % 2], DP1[(n + 1) % 2], DP2[(n + 1) % 2])


data = Solution()
costs = [[7,6,2]]
print(data.minCost(costs))
